#!/bin/sh

. /usr/share/common

CNET=172.16.0.1

start() {
	decrement_mac
	starting
	modprobe g_ncm iManufacturer=thingino host_addr=$(fw_printenv -n ethaddr) dev_addr=$ethaddr iProduct="NCM CDC Ethernet Gadget"
	usb-role -m device
	touch /run/udhcpd.leases
	start-stop-daemon -S -x /sbin/dnsd -- -i $CNET -c /etc/dnsd.conf -d
	start-stop-daemon -S -x /sbin/udhcpd -- -S -I $CNET /etc/udhcpd.conf 2>&1
}

case "$1" in
	start)
		start
		;;
	stop)
		true
		;;
	*)
		echo "Usage: $0 {start}"
		exit 1
		;;
esac

exit 0
